<template>
  <view class="bg-white" style="height: 100vh; padding-top: 100rpx">
    <cu-custom :bgColor="'bg-' + theme.backgroundColor" :isBack="true">
      <block slot="backText">返回</block>
      <block slot="content">会员卡号</block>
    </cu-custom>

    <view class="text-center text-lg">会员卡号</view>
    <view style="margin: 40rpx" class="flex justify-center">
      <ayQrcode
        ref="qrcode"
        :modal="modal_qr"
        :url="url"
        @hideQrcode="hideQrcode"
        :height="182"
        :width="182"
      />
    </view>
  </view>
</template>

<script>
const app = getApp();
// const wxbarcode = require("@/utils/barcodeindex.js");
import ayQrcode from "../../../components/ay-qrcode/ay-qrcode.vue";
export default {
  data() {
    return {
      theme: app.globalData.theme, //全局颜色变量
      url: "", // 要生成的二维码值
    };
  },

  components: {
    ayQrcode,
  },
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let {userCode} = uni.getStorageSync('user_info')
    console.log(userCode,'userCode');
    if(userCode){
      this.url = userCode
      this.showQrcode();//一加载生成二维码
    }
  },
  methods: {
    showQrcode() {
      let _this = this;
      this.modal_qr = true;
      setTimeout(function() {
          _this.$refs.qrcode.crtQrCode()
      }, 50)
    }
  },
};
</script>
<style>
@import "./index.css";
</style>
